package com.futao.dao;

import com.futao.entity.User;
import com.futao.service.GetSession;
import face.com.futao.dao.IUserDao;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author futao
 * Created on 18-6-7-上午11:30.
 */
@Repository
public class UserDao implements IUserDao {

    @Autowired
    private GetSession getSession;

    @Override
    public List<User> getUserByUserName(String userName) {
        Criteria criteria = getSession.getSession().createCriteria(User.class);
        if (userName != null && !userName.isEmpty()) {
            criteria.add(Restrictions.eq(User._name, userName));
        }
        List list = criteria.list();
        return (List<User>) list;
    }
}
